import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  plugins: [vue()],
  server: {
    port: 80,
    host: '0.0.0.0', // 支持外部访问
    open: true,
    cors: true, // 启用CORS支持
    https: false, // 如需HTTPS可设为true
    // 网络访问配置
    network: true, // 允许网络访问
    // 自定义响应头
    headers: {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
      'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
    }
  },
  // 构建配置
  build: {
    outDir: 'dist',
    assetsDir: 'assets',
    // 生产环境配置
    rollupOptions: {
      output: {
        manualChunks: {
          vendor: ['vue', 'vue-router'],
          animations: ['gsap', 'typed.js']
        }
      }
    }
  },
  // 预览配置
  preview: {
    port: 83,
    host: '0.0.0.0',
    open: true
  }
})
